<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet" />
<link href="assets/css/front/listCommonStyle.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<div class="row margin-left-10">
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div class="widget flat margin-top-0" style="margin: -10px 0 0px 0!important;">
			<div class="widget-header bordered-sky theme-bordered nopadding">
				<div class="widget-buttons widget-label nomargin-bottom">
					<label class="businessBtns">
						<ol class="breadcrumb" style="margin: 0;">
							<li style="color: #809fa6;">班级管理</li>
							<li class="active" style="color: #23a8f5;">班级变动</li>
						</ol>
					</label>
				</div>
			</div>
		</div>
	</div>
	<!-- 映射列表 -->
	<input type="hidden" name="classType" class="classType" value="1"/>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<div style="margin-bottom: 50px;clear: both;">
			<div class="widget searchCriteria flat" style="margin: 3px 20px 0px 0px!important;float: left">
				<div class="widget-header bordered-sky theme-bordered nopadding">
					<div class="widget-buttons widget-label nomargin-bottom">
						<label class="businessBtns">
							<@hp code="BJBD34707782777340-qz_classes"  params="[classType=1]" />
							<@hp code="BJBD34707782777340-gd_classes"  params="[classType=2]" />
						</label>
					</div>
				</div>
			</div>

			<div class="widget flat searchCriteria" style="margin: 0;float: right;">
				<div class="widget-header bordered-sky theme-bordered nopadding">
					<div class="widget-buttons" style="margin-bottom: 5px !important;">
						<!-- 业务按钮 begin -->
						<label class="businessBtns">
							<@hp code="BJBD34707782777340-list_add"  params="[serializeNum=${serializeNum},tssClassType=1]" />
							<@hp code="BJBD34707782777340-list_switch_date" />
                            <@hp code="BJBD34707782777340-exportData"  params="[searchFormId=${searchFormId}]" />
							<label class="margin-right-10">
								<a style="border-radius: 0px;border: none;background: #ffab00 !important;"
								   class="btn btn-warning shiny search margin-right-10"><i class="fa fa-search"></i>搜索
								</a>
							</label>
						</label>
						<label onclick="iconsChange()">
							<label>
								<a class="iconsChangeA" style="width: 13px;height: 13px;cursor: pointer;background: url('assets/img/nav-img/icon_hidden.png');display: block;-webkit-user-select:none; -moz-user-select:none; -ms-user-select:none;user-select:none;" value="1"></a>
							</label>
							<label style="color: #23a8f5 ;vertical-align: middle;padding-top:4px;">
								<span class="iconsChangeSpan" style="-webkit-user-select:none; cursor: pointer;-moz-user-select:none; -ms-user-select:none;user-select:none;">隐藏搜索栏</span>
							</label>
						</label>
					</div>
				</div>
			</div>
		</div>
		<div class="search_Bar" style="vertical-align: middle;clear: both;">
			<form id="${searchFormId}" action="${actionUrl}" class="searchConditions" method="POST">
				<input type="hidden" value="1" name="type"/>
				<label class="iconchange1 hidden" style="position: absolute;right: 10px;top: 0px;" >
					<a class="search_Bar_A" id="iconchangemore" style="color: #2a6496;cursor: pointer;" onclick="iconchangeShow(this)" value="1">筛选更多<i class="fa fa-chevron-down" style="padding-left: 5px"></i></a>
				</label>
				<div class="row searchInput" style="margin: 0;">
					<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">
						<label style="width: 78px">上课日期：</label>
						<label>
							<input id="d4313" type="text" name="startDate_begin" class="beginValue" value="${search_map.startDate_begin[0]}"
								   onFocus="WdatePicker({doubleCalendar:false,maxDate:'#F{$dp.$D(\'d4314\')}',dateFmt:'yyyy-MM-dd'})" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;"> 至
							<input id="d4314"  type="text" name="startDate_end" class="endValue"  value="${search_map.startDate_end[0]}"
								   onFocus="WdatePicker({doubleCalendar:false,minDate:'#F{$dp.$D(\'d4313\')}',dateFmt:'yyyy-MM-dd'})" style="width: 90px;height: 30px!important;padding-left:3px!important;border: 1px solid #c6d5d8;border-radius: 4px !important;">
						</label>
					</label>
					<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">
						<label style="width: 78px">周几上课：</label>
						<select class="form-select-1" style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" name="weekDay" >
							<option value="">请选择</option>
							<@dictionary groupCode="weekDay";dics>
								<#list dics as dic>
									<option value="${dic.code}">${dic.value}</option>
								</#list>
							</@dictionary>
						</select>
					</label>
					<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">
						<label style="width: 78px">上课教室：</label>
						<label>
							<label>
								<select class="form-select-1" name="roomId" id="roomId"
										style="
                                    width:200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;"
										value="">
								</select>
							</label>
						</label>
					</label>
					<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">
						<label style="width: 78px">授课老师：</label>
						<label>
							<select class="form-select-1" name="empAdminUserId" id="adminUserId"
									style="
                                    width:200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" >
							</select>
						</label>
					</label>
					<!--<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">-->
						<!--<label style="width: 78px">班级名称：</label>-->
						<!--<label>-->
							<!--<select class="form-select-1 nopadding-right " style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" name="name">-->
								<!--<option value="">请选择</option>-->
								<!--<@dictionary groupCode="name";dics>-->
									<!--<#list dics as dic>-->
										<!--<option value="${dic.code}">${dic.value}</option>-->
									<!--</#list>-->
								<!--</@dictionary>-->
							<!--</select>-->
						<!--</label>-->
					<!--</label>-->
					<label class="searchList search_Bar_item hidden" style="margin-bottom: 15px;margin-right: 40px;">
						<label style="width: 78px">课程名称：</label>
						<label>
							<select class="form-select-1 systemPid" name=""
									style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" >
								<option>请选择课程体系</option>
							</select><select class="form-select-1 courseId" name=""
											 style="width: 200px;height: 30px;border: 1px solid #c6d5d8;border-radius: 4px !important;" >
							<option>请选择课程名称</option>
						</select>
						</label>
					</label>
				</div>
			</form>
		</div>

		<div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
			<div class="widget-body no-padding">
				<div class="topPagingBar hidden">
					${pagingBar}
				</div>
				<div class="table-scrollable" style="border: none;" id="dataTable">
					<!-- 数据表列信息列表 -->
					<table class="table table-hover dataTable newtable">
						<thead>
						<tr>
							<th title="选择" class="checkboxColumnTh" >
								<div class="checkbox">
									<label>
										<input type="checkbox" class="chkAll">
										<span class="text"></span>
									</label>
								</div>
							</th>
							<th title="属性名">序号</th>
							<th>操作项</th>
							<!--<th title="班级名称">班级名称</th>-->
							<th title="学期">学期</th>
							<th title="课程名称">课程名称</th>
							<th title="课程开始日期">课程开始日期</th>
							<th title="课程结束日期">课程结束日期</th>
							<th title="上课时间">上课时间</th>
							<th title="周几上课">周几上课</th>
							<th title="上课教室">上课教室</th>
							<th title="授课老师">授课老师</th>
							<th title="课程次数">课程次数</th>
							<th title="剩余次数">剩余次数</th>
							<th title="单节消耗课时">单节消耗课时</th>
							<th title="创建人">创建人</th>
							<th title="创建日期">创建日期</th>
						</tr>
						</thead>
						<tbody id="tssClassesListtableScrollable">
						<#if page_bean.list?size==0>
							<tr>
								<td align="center">无数据</td>
							</tr>
						</#if>
						<#list page_bean.list as data>
							<tr>
								<td class="checkboxColumnTd">
									<div class="checkbox">
										<label>
											<input type="checkbox" class="chk"  name="id" value="${data.id}">
											<span class="text"></span>
										</label>
									</div>
								</td>
								<td>${data_index+1+(page_bean.pageNo-1)*page_bean.pageSize}</td>
								<td align="center">
                                    <@hp code="BJBD34707782777340-list_class_change" params="[tartgetDateId=${data.id}]" />
									&nbsp;
                                    <@hp code="BJBD34707782777340-list_class_roster" params="[tartgetDateId=${data.id}]" />
								</td>
								<!--<td><a class="showClassDetailTd" tartgetDateId="${data.id}">${(data.name???string(data.name?html,"未设置"))!'未设置'}</a></td>-->
								<td>${(data.semester???string(data.semester?html,""))!''}</td>
								<td><a class="showClassDetailTd" tartgetDateId="${data.id}">${(data.tssCourse.idEntity.name???string(data.tssCourse.idEntity.name?html,""))!''}</a></td>
								<td>${(data.startDate???string(data.startDate?string("yyyy-MM-dd"),""))!''}</td>
								<td>${(data.endDate???string(data.endDate?string("yyyy-MM-dd"),""))!''}</td>
								<td>${(data.startTime???string(data.startTime?string("HH:mm"),""))!''} — ${(data.endTime???string(data.endTime?string("HH:mm"),""))!''}</td>
								<td><@dictionary groupCode="weekDay" dictionaryCode="${data.weekDay}" ;weekDay>${weekDay.value }</@dictionary></td>
								<td>${(data.tssClassRoom.name???string(data.tssClassRoom.name?html,""))!''}</td>
								<td>${(data.empSysAdminUser.realName???string(data.empSysAdminUser.realName?html,""))!''}</td>
								<td>${(data.pitchNumber???string(data.pitchNumber?html,""))!''}</td>
								<td>${(data.surplusPitchNumber???string(data.surplusPitchNumber?html,""))!''}</td>
								<td>${(data.expendClassHour???string(data.expendClassHour?html,""))!''}</td>
								<td>${(data.sysAdminUser.userName???string(data.sysAdminUser.userName?html,""))!''}</td>
								<td>${(data.createTime???string(data.createTime?html,""))!''}</td>
							</tr>
						</#list>
						</tbody>
					</table>
				</div>
				${pagingBar}
			</div>
		</div>
	</div>
</div>
<script>
$(".selectpicker").select2();
/**
 * 请求列表
 * @param that
 */
function requestClassesList(that) {
    var type = $(that).attr("classType");
    javascript:toView('tssClassesController/tssClassesList.do?type='+type,true,'POST',{pageSize:10})
}

/**
 * 创建亲子班级
 * @param that
 */
function showDialogAddClass(that) {
    var tssClassType = $(that).attr("tssClassType");
    var serializeNum = $(that).attr("serializeNum");
    ajaxRequest("tssClassesController/toEditView.do", {
        serializeNum: serializeNum,
        tssClassType: tssClassType
    }, function (html) {
        getTopWin().bootbox.dialog({
            message: html,
			className:"bootboxDiv tssClassesListDialog"
        });
        $(".modal-header").find(".bootbox-close-button").removeClass("close");
        $(".modal-header").find(".bootbox-close-button").html("");
    }, function () {
        ajaxError("加载页面失败!")
    }, "get", "html")


}

/**
 * 查看班级详情
 * @param that
 */

$("#tssClassesListtableScrollable").on("click",".showClassDetailTd",function () {
    var tartgetDateId = $(this).attr("tartgetDateId");
    var classType=$(".classType").val();
    ajaxRequest("tssClassesController/getListByClassId.do", {
        classId: tartgetDateId,
        classType:classType
    }, function (html) {
        getTopWin().bootbox.dialog({
            message: html,
            title: "班级详情",
            className: 'myDialog tssClassesListDialog'
        });
        $(".modal-header").find(".bootbox-close-button").removeClass("close");
        $(".modal-header").find(".bootbox-close-button").html("");
    }, function () {
        ajaxError("加载页面失败!")
    }, "get", "html")
})

/**
 * 查看花名册
 * @param that
 */
function showClassRoster(that) {
    var tartgetDateId = $(that).attr("tartgetDateId");
    var classType=$(".classType").val();
    ajaxRequest("tssClassesController/getClassRosterById.do", {
        pageSise:10,
        classId: tartgetDateId,
        classType:classType
    }, function (html) {
        getTopWin().bootbox.dialog({
            message: html,
            title: "花名册",
            className: 'myDialog tssClassesListDialog'
        });
        $(".modal-header").find(".bootbox-close-button").removeClass("close");
        $(".modal-header").find(".bootbox-close-button").html("");
    }, function () {
        ajaxError("加载页面失败!")
    }, "post", "html")
}
/**
 * 班级变动
 * @param that
 */
function showClassChange(that) {
    var tartgetDateId = $(that).attr("tartgetDateId");
    var classType=$(".classType").val();
    ajaxRequest("tssClassesController/getClassChangeById.do", {
        pageSise:10,
        classId: tartgetDateId,
        classType:classType
    }, function (html) {
        getTopWin().bootbox.dialog({
            message: html,
            title: "班级变动",
            className: 'myDialog tssClassesChange',
        });
        $(".modal-header").find(".bootbox-close-button").removeClass("close");
        $(".modal-header").find(".bootbox-close-button").html("");
//		$(".modal-header").append("<button type='button' class='bootbox-expand-button expand'  onclick='expandView()'></button>")
    }, function () {
        ajaxError("加载页面失败!")
    }, "post", "html")
}

/**
 * 日期对调
 * @param
 * */
function switchDate(){

    ajaxRequest("tssClassesController/switchDate.do", {
    }, function (html) {
        getTopWin().bootbox.dialog({
            message: html,
            title: "班级对调",
            className: 'myDialog switchDateDialog'
        });
        $(".modal-header").find(".bootbox-close-button").removeClass("close");
        $(".modal-header").find(".bootbox-close-button").html("");
    }, function () {
        ajaxError("加载页面失败!")
    }, "get", "html")
}

/**
 * 导出数据
 * @param formId 条件表单id
 * @param templateName 导出的文件名
 */
function exportData(that, templateName) {
    var ids = "";
    $("[name='id']:checked").each(function(){
        ids += "," +$(this).val();
    });
    ids = ids.substring(1);
    var params = $(that).attr("searchFormId");
    var exportIframe = ' <iframe class="hidden" id="exportIframe" name="exportIframe"></iframe>';
    var exportSrc ="tssClassesController/exportExcle.do";
    var $exportForm = $('<form method="post" target="exportIframe" action="' + exportSrc + '" id="exportForm"></form>');
    $("#" + formId).find("input").map(function (i, input) {
        var $input = $(input);
        var name = $input.attr("name");
        var val = $input.val();
        if (name) {
            $exportForm.append('<input type="hidden" name="' + name + '" value="' + val + '">');
        }
    });

    //追加参数
    $exportForm.append('<input type="hidden" name="ids" value="'+ids+'">');
    $exportForm.append('<input type="hidden" name="templateName" value="' + templateName + '">');
    $exportForm.append('<input type="hidden" name="loginAdminUserId" value="${loginUserId}">');

    /**
     * 定义标识
     * @param flag:代表有无条件参数
     * */
    var flag = 0;
	var type = 1;

    $exportForm.append('<input type="hidden" name="flag" value='+flag+'>');
    $exportForm.append('<input type="hidden" name="type" value='+type+'>');

    //删除并提交表单
    $("body #exportIframe").remove();
    $("body #exportForm").remove();
    $("body").append(exportIframe);
    $("body").append($exportForm);
    $exportForm.submit();
};


//    隐藏显示搜索
function iconsChange() {
    if($(".iconsChangeA").val()==1){
        $(".iconsChangeA").val("0");
        $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_hidden.png')");
        $(".iconsChangeSpan").html("隐藏搜索栏");
        $(".search_Bar").removeClass("hidden");
    }else{
        $(".iconsChangeA").val("1");
        $(".iconsChangeA").css("background","url('assets/img/nav-img/icon_show.png')");
        $(".iconsChangeSpan").html("显示搜索栏");
        $(".search_Bar").addClass("hidden");
    }
}

//    筛选下拉框
setTimeout(function () {
    var size = $(".search_Bar_item").size();
    if (size > 8) {
        $(".iconchange1").removeClass("hidden");
        $(".search_Bar_item").each(function () {
            var index = $(this).index();
            if (index <= 8) {
                $(this).removeClass("hidden")
            }

        })
    } else {
        $(".iconchange1").addClass("hidden");
        $(".search_Bar_item").each(function () {
            $(this).removeClass("hidden")
        })
    }

    $(".iconDialogTd").each(function (tr,trItem) {
        var $tr = $(trItem);
        var sizeTd = $tr.find(".showDialogTd").size();
        if(sizeTd>5){
            $tr.find(".iconchangeTd").removeClass("hidden");
            $tr.find(".showDialogTd").each(function (a,aItem) {
                var $a = $(aItem);
                if(($a.index()+1)>5){
                    var html = $a.get(0);
                    $a.remove();
                    $tr.find(".popover-content").get(0).append(html);
                    $a.addClass("appendTdA")
                }
            })

        }else{
            $tr.find(".iconchangeTd").addClass("hidden");
            $tr.find(".showDialogTd").each(function () {
                $tr.removeClass("hidden");
            })
        }
    })

}, 10);



function iconchangeShow(that) {

    if($(that).attr("value")==1){
        $(that).attr("value","0");
        $(".iconchange1 .fa").removeClass("fa-chevron-down").addClass("fa-chevron-up");
        $(".search_Bar_item").each(function () {
            $(this).removeClass("hidden")
        })
    }else{
        $(that).attr("value","1");
        $(".iconchange1 .fa").removeClass("fa-chevron-up").addClass("fa-chevron-down");
        $(".search_Bar_item").each(function () {
            var index = $(this).index();
            if (index <= 8) {
                $(this).removeClass("hidden")
            }else{
                $(this).addClass("hidden")
            }

        })
    }

}

function iconchangeArrow(that) {
    if($(that).attr("value")==0) {
        $(that).attr("value","1");
        $(that).find(".fa").removeClass("fa-sort-desc").addClass("fa-sort-up");
        $(that).find(".fa").css("top","5px");
        $(that).next().removeClass("hidden");

    }else{
        $(that).attr("value","0");
        $(that).find(".fa").removeClass("fa-sort-up").addClass("fa-sort-desc");
        $(that).find(".fa").css("top","0px");
        $(that).next().addClass("hidden");
    }
}
</script>
<script>
    $(function(){
        /**
         * 获取教师
         */
        ajaxRequest("sysAdminUserController/getPostListByDuty.do",{
            duty:3
        }, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>']; //<option value="0">请选择</option>
            for (var i = 0; i< data.length; i++) {
                arr.push('<option value="'+data[i].id+'">'+data[i].realName+'</option>')
            }
            $("#adminUserId").html(arr.join(''))
        },function(){
            ajaxError("加载员工信息失败");
        }, "post","json");

        /**
         * 获取教室
         */
        ajaxRequest("tssClassRoomController/getClassRoomList.do",null, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>']; //<option value="0">请选择</option>
            for (var i = 0; i< data.length; i++) {
                arr.push('<option value="'+data[i].id+'">'+data[i].name+'</option>')
            }
            $("#roomId").html(arr.join(''))
        },function(){
            ajaxError("加载教室信息失败");
        }, "post","json");

    });
    $(".selectpicker_879F8B4CDB164BA094410DA4BE75D179").select2();
    $("#editForm_879F8B4CDB164BA094410DA4BE75D179").bind("ajaxSubmitCallback", function (event, result) {
        if (result.resCode == 200) {
            alert("保存成功");
            bootbox.hideAll();
        }
    });
</script>
<script>

    /**
     * 获取课程体系
     */
    $(function(){
        ajaxRequest("sysCourseSystemController/courseSystemList.do",{
            type:1
        }, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>'];
            $.each(data,function(i,t){
                arr.push('<option value="'+t.id+'">'+t.name+'</option>')
            })
            $(".systemPid").html(arr.join(''))
        },function(){
            ajaxError("加载课程体系失败");
        }, "get","json")
    });

    /**
     * 获取课程体系下课程名称
     */
    $(".systemPid").change(function(){
        var nowSelectedProvince=$(this).val();
        ajaxRequest("sysCourseSystemController/getChildrens.do", {
            pId: nowSelectedProvince,
        }, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>'];
            $.each(data,function(i,t){
                arr.push('<option value="'+t.id+'">'+t.name+'</option>')
            })
            $(".courseId").html(arr.join(''))

        }, function () {
            ajaxError("加载课程名称失败")
        }, "get", "json")
    });

</script>